#pragma once

#include <iostream>
#include <pthread.h>

class Lock
{
public:
   Lock(pthread_mutex_t* mtx):_mtx(mtx)
   {}

   void lock()
   {
      pthread_mutex_lock(_mtx);
   }

   void unlock()
   {
    pthread_mutex_unlock(_mtx);
   }

private:
   pthread_mutex_t* _mtx;
};

class LockGuard
{
public:
   LockGuard(pthread_mutex_t* mtx):_lk(mtx)
   {}
   
   void lockguard()
   {
     _lk.lock();
   }
   
   ~LockGuard()
   {
     _lk.unlock();
   }

private:
   Lock _lk;
};



